package com.kaifamiao.methods;

public class Dog {

    public void increment( int counter ){
        System.out.println( "before ++: " + counter );
        counter++;
        System.out.println( "after ++: " + counter );
    }

    // main 线程调用 Dog类的 main 方法会导致产生与之相关的栈帧并压入虚拟机栈栈顶
    public static void main(String[] args) {
        int counter = 1000;
        Dog d = new Dog();
        System.out.println( "before increment: " + counter );
        // main 调用 d 的 increment 导致产生与之相关的栈帧并压入虚拟机栈栈顶
        d.increment( counter );
        System.out.println( "after increment: " + counter );
    }

}
